# PortAudio library
PORTAUDIO=./portaudio/libportaudio.a

# RealTimeDigitalAudioProcessing library
RTDAP=librtdap.a
OBJS=Audio.o DSP.o DTMF.o Filter.o Generate.o RMS.o VAD.o Gain.o

# Tests
TESTS=test/Test_DTMF test/Test_RMS test/Test_VAD test/Test_Gain

# Compiler options
CC_FLAGS=-Wall -DUNIX
CC_INC=-I/usr/include -I. -I./portaudio

# Linker options
LD_PATHS=-Lportaudio -L. -L/usr/lib
LD_LIBS=-lrtdap -lportaudio -lpthread

all: $(TESTS)

clean:
	rm -rf $(OBJS) $(TESTS) $(patsubst %, %.o,$(TESTS))

realclean: clean
	make -C ./portaudio clean
	rm -rf doc

doc: 
	doxygen

$(PORTAUDIO):
	make -C ./portaudio

$(RTDAP): $(OBJS)
	ar rc $(RTDAP) $(OBJS)
	ranlib $(RTDAP)

libs:$(RTDAP) $(PORTAUDIO)

test/Test_%:libs test/Test_%.o
	g++ -o $@ $(LD_PATHS) $@.o $(LD_LIBS)

%.o: %.cpp
	g++ $(CC_FLAGS) $(CC_INC) -c -o $@ $<

